from typing import Annotated

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session

import models
from auth import get_current_active_user
from db import get_db

router = APIRouter(prefix="/api/product", tags=["产品"])

@router.delete("/{user_id}")

def delete_user(current_user: Annotated[models.User, Depends(get_current_active_user)],
                Product_id: int, db: Session = Depends(get_db)):
    user = db.query(models.Product).filter(models.Product.id == Product_id).first()
    if user is None:
        raise HTTPException
    db.delete(user)
    db.commit()
    return {"message": "删除成功"}


